module.exports = app => {
  const Sequelize = app.Sequelize;
  const userProjectCollect = app.model.define('user_project_collects', {
    id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true },
    user_id: { type: Sequelize.INTEGER, allowNull: false, comment: '用户ID' },
    project_id: { type: Sequelize.INTEGER, allowNull: false, comment: '项目ID' },
  }, {
    paranoid: false, // 不启用软删除
  });

  userProjectCollect.associate = function() {
    // 定义关联关系
    userProjectCollect.belongsTo(app.model.Users, { foreignKey: 'user_id' });
    userProjectCollect.belongsTo(app.model.Projects, { foreignKey: 'project_id' });
  };

  return userProjectCollect;
};
